package com.team.childapp.http.base;


import com.team.childapp.util.JsonSerializer;

import java.util.HashMap;
import java.util.Map;

/**
 * Create on: 9/16/21
 * by Mr.Zhu
 * Description: volley框架请求参数基类bean
 */
public class BaseReqBean {
    private Map<String, Object> map;
    private String token;
    private String os = "Android";

    public BaseReqBean()
    {
        token = "";
        os = "Android";
        getMap().clear();
    }

    //获取token
    public String getToken()
    {
        if(token == null)
        {
            token = "";
        }
        return token;
    }

    //设置token
    public void setToken(String token)
    {
        this.token = token;
    }

    //获取os
    public String getOs()
    {
        if(os == null)
        {
            os = "";
        }
        return os;
    }

    //设置os
    public void setOs(String os)
    {
        this.os = os;
    }

    public Map<String, Object> getMap()
    {
        if (map == null)
        {
            map = new HashMap<>();
        }
        return map;
    }

    public void setMap(Map<String, Object> map)
    {
        this.map = map;
    }

    //获取封装的请求参数bean
    public Map<String, Object> getReqMap()
    {
        Map<String, Object> reqMap = new HashMap<>();
        reqMap.putAll(getMap());
//        reqMap.put("token", getToken());
//        reqMap.put("os", getOs());
        return reqMap;
    }

    //转换成字符串
    public String toString()
    {
        String string ="";
        try
        {
            string = JsonSerializer.serialize(getReqMap());
        }
        catch (Exception e)
        {
            string ="";
        }
        return string;
    }
}
